﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twodi.Aspect.Interfaces;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Twodi.Interfaces;

namespace Twodi.Implemented
{
    public abstract class AbstractSprite : AbstractRenderable, ITextureAspect
    {
        public AbstractSprite(Game game)
            : base(game)
        {

        }

        /// <summary>
        /// Renderizar imagem.
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Render(GameTime gameTime)
        {
            if (ValidSpriteBatch)
            {
                SpriteBatch.Draw(Texture, Position, Source, AlphaColor, Rotation, Origin, Scale, SpriteEffects.None, 0);
            }
        }

        /// <summary>
        /// Rectangle de Source do Textured.
        /// </summary>
        public virtual Rectangle? Source
        {
            get
            {
                return TextureProperties.Source;
            }
            set
            {
                TextureProperties.Source = value;
            }
        }

        public Texture2D Texture
        {
            get
            {
                return this.TextureProperties.Texture;
            }
            set
            {
                this.TextureProperties.Texture = value;
            }
        }

        public Color AlphaColor
        {
            get
            {
                return this.TextureProperties.AlphaColor;
            }
            set
            {
                this.TextureProperties.AlphaColor = value;
            }
        }

        public ITexture TextureProperties
        {
            get;
            set;
        }
    }
}
